package com.heima.behavior.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.behavior.mapper.ApBehaviorMapper;
import com.heima.behavior.service.ApBehaviorService;
import com.heima.model.behavior.pojo.ApBehaviorEntry;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class ApBehaviorServiceImpl extends ServiceImpl<ApBehaviorMapper, ApBehaviorEntry> implements ApBehaviorService {


    @Override
    public ApBehaviorEntry findByUserIdOrEquipmentId(Integer userId, Integer equipmentId) { //ApArticleServiceImpl调用，equipmentId无实际意义
        if (userId==null||equipmentId==null){
            return null;
        }
        ApBehaviorEntry behaviorEntry = getOne(Wrappers.<ApBehaviorEntry>lambdaQuery().eq(ApBehaviorEntry::getEntryId, userId));

        return behaviorEntry;
    }


    /**
     * 根据用户id查询实体对象
     * @param userId
     * @return
     */
    @Override
    public ApBehaviorEntry findByUserId(Integer userId) {

        ApBehaviorEntry behaviorEntry = getOne(Wrappers.<ApBehaviorEntry>lambdaQuery().eq(ApBehaviorEntry::getEntryId, userId));
        return behaviorEntry;
    }
}
